﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Threading;

namespace SpringGraph.Utils
{
    public class DispatcherTimerWithArgs
    {
        private DispatcherTimer _Timer;

        public DispatcherTimerWithArgs()
        {
            _Timer = new DispatcherTimer();
            _Timer.Tick += new EventHandler(_Timer_Tick);
        }

        public TimeSpan Interval
        {
            get
            {
                return _Timer.Interval;
            }
            set
            {
                _Timer.Interval = value;
            }
        }

        public bool IsEnabled
        {
            get
            {
                return _Timer.IsEnabled;
            }
        }

        public void Start()
        {
            _Timer.Start();
        }

        public void Stop()
        {
            _Timer.Stop();
        }

        public object Args
        {
            get;
            set;
        }

        void _Timer_Tick(object sender, EventArgs e)
        {
            if (Tick != null)
            {
                Tick(this, new DispatcherTimerArgs()
                {
                    Args = Args
                });
            }
        }

        public event EventHandler<DispatcherTimerArgs> Tick;
    }

    public class DispatcherTimerArgs : EventArgs
    {
        public object Args
        {
            get;
            set;
        }
    }
}
